package com.yida.gwj.api.factory;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import com.yida.common.core.domain.R;
import com.yida.gwj.api.domain.dto.GwjGVoteProjectStatisticsDataDTO;
import com.yida.gwj.api.domain.dto.GwjGVoteResultInnerDTO;
import com.yida.gwj.api.domain.request.GwjVoteResultInnerRequest;
import com.yida.gwj.api.service.RemoteGwjVoteService;

/**
 * 公维金服务降级处理
 *
 * @author lqq
 */
@Component
public class RemoteGwjVoteFallbackFactory implements FallbackFactory<RemoteGwjVoteService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteGwjVoteFallbackFactory.class);

    @Override
    public RemoteGwjVoteService create(Throwable throwable) {
        log.error("公维金投票内网服务调用失败:{}", throwable.getMessage());
        return new RemoteGwjVoteService() {
            @Override
            public R<List<GwjGVoteResultInnerDTO>> innerVoteResult(GwjVoteResultInnerRequest request, String source) {
                return R.fail("公维金业务查询投票结果:{}" + throwable.getMessage());
            }

            @Override
            public R<GwjGVoteProjectStatisticsDataDTO> innerGVoteProjectStatistics(Long bizNum, String source) {
                return R.fail("公维金业务查询投票统计结果:{}" + throwable.getMessage());
            }
        };
    }

}
